#include "loScriptMoveNext.hpp"
#include "loNetList.hpp"
#include "loScriptMove.hpp"

loScriptMoveNext::loScriptMoveNext()
{
}

loScriptMoveNext::loScriptMoveNext( int from, int to )
  : from_(from), to_(to)
{
}

loScriptMoveNext::loScriptMoveNext(const loScriptMoveNext &m)
  : from_(m.from_), to_(m.to_)
{
}

loScriptMoveNext::~loScriptMoveNext()
{
}

edaMoveGen* loScriptMoveNext::clone() const
{
  return new loScriptMoveNext(*this);
}

bool loScriptMoveNext::generate(edaMove *move, const edaSolution &sol)
{
  loScriptMove *mymove = (loScriptMove *)move;
  int nid = mymove->getScript();

  if ( nid == to_ )
    return false;
  else {
    nid ++;
    mymove->setScript( nid );
    return true;
  }
}

void loScriptMoveNext::Serialize(edaBuffer &buf, bool pack)
{
  edaMoveGen::Serialize(buf, pack);

  if (pack)
  {
    buf.Pack( &from_, 1 );
    buf.Pack( &to_, 1 );
  }
  else
  {
    buf.UnPack( &from_, 1 );
    buf.UnPack( &to_, 1 );
  }
}
